﻿(function (_0) {
    var _1 = {};
    var _2 = {};
    var _3 = {};
    var _50 = {};
    var _51 = {};
    var _52 = undefined;
    var _53 = undefined;
    var _54 = undefined;
    function _4(_5, _6) {
        var _7 = false;
        var _8 = document.createElement("script");
        _8.type = "text/javascript";
        _8.language = "javascript";
        _8.src = _5;
        _8.onload = _8.onreadystatechange = function () {
            if (!_7 && (!_8.readyState || _8.readyState == "loaded" || _8.readyState == "complete")) {
                _7 = true;
                _8.onload = _8.onreadystatechange = null;
                if (_6) {
                    _6.call(_8);
                }
            }
        };
        document.getElementsByTagName("head")[0].appendChild(_8);
    };
    function _9(_a, _b) {
        _4(_a, function () {
            document.getElementsByTagName("head")[0].removeChild(this);
            if (_b) {
                _b();
            }
        });
    };
    function _c(_d, _e) {
        var _f = document.createElement("link");
        _f.rel = "stylesheet";
        _f.type = "text/css";
        _f.media = "screen";
        _f.href = _d;
        document.getElementsByTagName("head")[0].appendChild(_f);
        if (_e) {
            _e.call(_f);
        }
    };
    function _10(_11, _12) {
        _3[_11] = "loading";
        var _13 = _1[_11];
        var _14 = "loading";
        var _15 = (soul.css && _13["css"]) ? "loading" : "loaded";
        if (soul.css && _13["css"]) {
            if (/^http/i.test(_13["css"])) {
                var url = _13["css"];
            } else {
                var url = soul.base + "themes/" + soul.theme + "/" + _13["css"];
            }
            _c(url, function () {
                _15 = "loaded";
                if (_14 == "loaded" && _15 == "loaded") {
                    _16();
                }
            });
        }
        if (/^http/i.test(_13["js"])) {
            var url = _13["js"];
        } else {
            var url = soul.base + "plugins/" + _13["js"];
        }
        _4(url, function () {
            _14 = "loaded";
            if (_14 == "loaded" && _15 == "loaded") {
                _16();
            }
        });
        function _16() {
            _3[_11] = "loaded";
            soul.onProgress(_11);
            if (_12) {
                _12();
            }
        };
    };
    function _17(_18, _19) {
        var mm = [];
        var _1a = false;
        if (typeof _18 == "string") {
            add(_18);
        } else {
            for (var i = 0; i < _18.length; i++) {
                add(_18[i]);
            }
        }
        function add(_1b) {
            if (!_1[_1b]) {
                return;
            }
            var d = _1[_1b]["dependencies"];
            if (d) {
                for (var i = 0; i < d.length; i++) {
                    add(d[i]);
                }
            }
            mm.push(_1b);
        };
        function _1c() {
            if (_19) {
                _19();
            }
            soul.onLoad(_18);
        };
        var _1d = 0;
        function _1e() {
            if (mm.length) {
                var m = mm[0];
                if (!_3[m]) {
                    _1a = true;
                    _10(m, function () {
                        mm.shift();
                        _1e();
                    });
                } else {
                    if (_3[m] == "loaded") {
                        mm.shift();
                        _1e();
                    } else {
                        if (_1d < soul.timeout) {
                            _1d += 10;
                            setTimeout(arguments.callee, 10);
                        }
                    }
                }
            } else {
                if (soul.locale && _1a == true && _2[soul.locale]) {
                    var url = soul.base + "locale/" + _2[soul.locale];
                    _9(url, function () {
                        _1c();
                    });
                } else {
                    _1c();
                }
            }
        };
        _1e();
    };
    soul = { configs: _50, modules: _1, locales: _2, services: _51, base: ".", userid: "0690f541-7773-445c-9f48-a7a0427686d6", theme: "default", css: true, locale: null, timeout: 2000, load: function (_1f, _20) {
        if (/\.css$/i.test(_1f)) {
            if (/^http/i.test(_1f)) {
                _c(_1f, _20);
            } else {
                _c(soul.base + _1f, _20);
            }
        } else {
            if (/\.js$/i.test(_1f)) {
                if (/^http/i.test(_1f)) {
                    _4(_1f, _20);
                } else {
                    _4(soul.base + _1f, _20);
                }
            } else {
                _17(_1f, _20);
            }
        }
    }, onProgress: function (_21) {
    }, onLoad: function (_22) {
    }
    };
    var _23 = document.getElementsByTagName("script");
    for (var i = 0; i < _23.length; i++) {
        var src = _23[i].src;
        if (!src) {
            continue;
        }
        var m = src.match(/soul\.js(\W|$)/i);
        if (m) {
            soul.base = src.substring(0, m.index);
        }
    }

    $.ajaxSettings.async = false;
    _52 = $("head").attr("id");
    _53 = $("head").attr("include");
    _54 = $("head").attr("code");
    if (_52 == undefined) {
        return;
    }
    else {
        _1[_52] = {};
    }
    if (_53 != undefined) {
        _1[_52].dependencies = [];
        $(_53.split("|")).each(function (i, n) {
            _1[_52].dependencies.push(n);
        });
    }
    if (_54 != undefined) {
        _1[_52].js = _54;
    }
    //_53 = $("head").attr("plus").split("|");
    if (_52 == "index") {
        soul.base = "";
    }
    else if (_52 == "home") {
        soul.base = "../";
    }
    else {
        soul.base = "../../";
    }
    $.getJSON(soul.base + _0, function (_d) {
        if (Object.hasOwnProperty.call(_d, "configs")) {
            $.extend(_50, _d["configs"]);
            if (Object.hasOwnProperty.call(_d["configs"], "modules")) {
                $.extend(_1, _d["configs"]["modules"]);
            }
            if (Object.hasOwnProperty.call(_d["configs"], "locales")) {
                $.extend(_2, _d["configs"]["locales"]);
            }
            if (Object.hasOwnProperty.call(_d["configs"], "theme")) {
                soul.theme = _d["configs"]["theme"];
            }
            if (Object.hasOwnProperty.call(_d["configs"], "locale")) {
                soul.locale = _d["configs"]["locale"];
            }
        }
        if (Object.hasOwnProperty.call(_d, "services")) {
            $.extend(_51, _d["services"]);
        }
    });
    $.ajaxSettings.async = true;

    window.using = soul.load;
    if (window.jQuery) {
        jQuery(function () {
            soul.onProgress = function (name) {
                if (name == "mask") {
                    $.mask();
                }
                else if (name == "parser") {

                }
                else if (name == "log") {
                    onlog();
                }
            }
            soul.onLoad = function (name) {
                if (name == "index") {
                    window.moveTo(1, 0);
                    window.resizeTo(screen.availWidth, screen.availHeight);
                }
                if (Object.hasOwnProperty.call(jQuery, "parser")) {
                    jQuery.parser.parse();
                }
                if (name == "index") {
                    $("body").layout("panel", "north").panel({ onLoad: function () {
                        core.Init();
                    }
                    });
                    $("body").layout("panel", "north").panel("refresh", "Pages/Modules/Head.html");
                }
                if (Object.hasOwnProperty.call($, "mask")) {
                    $.mask.hide();
                }
            }

            soul.load(_52, function () { });
        });
    }
})("Config/FrameworkConfig.cf");
